home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1998 July / EnigmA AMIGA RUN 29 (1998)(G.R. Edizioni)(IT)[!][issue 1998-07 & 08].iso / recent / grabur.lha / graburl / regexp.txt < prev   
Text File  |  1998-01-05  |  2KB  |  54 lines

  1. This is a part of the output from "man regexp" on my computer.
  2.  
  3. Not extremely clear the first time you read it, but should be enough to
  4. start with regular expressions.
  5.  
  6. I put a couple of examples at the end of this file.
  7.  
  8. REGULAR EXPRESSION SYNTAX
  9.      A regular expression is zero or more branches, separated by |'.  It
  10.      matches anything that matches one of the branches.
  11.  
  12.      A branch is zero or more pieces, concatenated.  It matches a match for
  13.      the first, followed by a match for the second, etc.
  14.  
  15.      A piece is an atom possibly followed by `*', `+', or `?'.  An atom fol-
  16.      lowed by `*' matches a sequence of 0 or more matches of the atom.  An
  17.      atom followed by `+' matches a sequence of 1 or more matches of the atom.
  18.      An atom followed by `?' matches a match of the atom, or the null string.
  19.  
  20.      An atom is a regular expression in parentheses (matching a match for the
  21.      regular expression), a range (see below), `.'  (matching any single char-
  22.      acter), `^' (matching the null string at the beginning of the input
  23.      string), `$' (matching the null string at the end of the input string), a
  24.      `\' followed by a single character (matching that character), or a single
  25.      character with no other significance (matching that character).
  26.  
  27.      A range is a sequence of characters enclosed in `[]'.  It normally match-
  28.      es any single character from the sequence.  If the sequence begins with
  29.      `^', it matches any single character not from the rest of the sequence.
  30.      If two characters in the sequence are separated by `-', this is shorthand
  31.      for the full list of ASCII characters between them (e.g. `[0-9]' matches
  32.      any decimal digit).  To include a literal `[' in the sequence, make it
  33.      the first character (following a possible `^').  To include a literal
  34.      `-', make it the first or last character.
  35.  
  36. A couple of examples
  37. ~~~~~~~~~~~~~~~~~~~~
  38. Pattern: dre
  39. Matches: andrew.com
  40.  
  41. Pattern: jp.*g
  42. Matches: hey.jpg ho.jpyg boo.jpxxxxg
  43.  
  44. Pattern: jpe+g
  45. Matches: hey.jpeg hey.jpeeg
  46. Dont ma: hey.jpg
  47.  
  48. Pattern: \.(gif|jpe*g)
  49. Matches: hello.giffe hello.gif banner.jpg banner.jpeg banner.jpeeg
  50.  
  51. Pattern: \.(gif|jpe*g)$
  52. Matches: hello.gif banner.jpg banner.jpeg
  53. Dont ma: hello.giffe
  54.